import argparse
import sys
from utils.constant import __version__
from utils.get_packet import Capture


def parse_args():
    if '--version' in sys.argv:
        print(__version__)
        exit(0)

    parser = argparse.ArgumentParser(
        description='start api2har service')
    parser.add_argument('--config', nargs='?', action='store', default='config.yml', help='config配置文件所在路径')
    args = parser.parse_args()
    return args


def api2har():
    args = parse_args()
    Capture(**args.__dict__).run()


if __name__ == '__main__':
    api2har()
